<template>
  <div class="toast" v-show="isShow">
      <div>{{message}}</div>
  </div>
</template>

<style scoped>
  .toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    border-radius: 6px;
    color: #fff;
    background-color: rgba(0, 0, 0, .75);
    z-index: 999;

  }
</style>

<script>
  export default {
    name: '',
    data() {
      return {
        message: '',
        isShow: false,
      }
    },
    methods: {
      show(message = '消息提示', duration = 3000) {
        this.isShow = true;
        this.message = message;
        setTimeout(() => {
          this.isShow = false;
          this.message = '';
        }, duration)
      }
    },
  }
</script>